package web.ip;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @description
 * @className IpAddressDemo
 * @package web.ip
 * @author dongww@hsyuntai.com
 * @date 2020/3/10 16:17
 * @copyright 版权归 HSYUNTAI 所有
 */
public class IpAddressDemo {
    public static void main(String[] args) throws UnknownHostException{
        InetAddress address = InetAddress.getByName("DESKTOP-61K2GK2");
        System.out.println(address);

        InetAddress address1 = InetAddress.getByName("10.26.190.63");
        System.out.println(address1);

        InetAddress address2[] = InetAddress.getAllByName("www.baidu.com");
        System.out.println(address2.length);
        System.out.println(address2[0]);
        System.out.println(address2[1]);

        System.out.println(InetAddress.getLocalHost().getHostName());
        System.out.println(InetAddress.getLocalHost().getHostAddress());

    }
}